﻿@using Xunit;
@inherits TestContext
@code
{
    [Fact]
    public void FluentButton_Title()
    {
        // Arrange && Act
        var cut = Render(@<FluentButton Title="My Title">My button</FluentButton>);

        // Assert
        cut.Verify();
    }

    [Fact]
    public void FluentButton_BackgroundColor()
    {
        // Arrange && Act
        var cut = Render(@<FluentButton Id="MyButton" BackgroundColor="#ff0000">My button</FluentButton>);

        // Assert
        cut.Verify();
    }

    [Fact]
    public void FluentButton_Color()
    {
        // Arrange && Act
        var cut = Render(@<FluentButton Id="MyButton" Color="#00ff00">My button</FluentButton>);

        // Assert
        cut.Verify();
    }

    [Fact]
    public void FluentButton_BackgroundColorColor()
    {
        // Arrange && Act
        var cut = Render(@<FluentButton Id="MyButton" BackgroundColor="#ff0000" Color="#00ff00">My button</FluentButton>);

        // Assert
        cut.Verify();
    }

    [Fact]
    public void FluentButton_OnClick()
    {
        bool clicked = false;

        // Arrange
        var cut = Render(@<FluentButton OnClick="@(e => { clicked = true; } )">
                             My button
                          </FluentButton>);

        // Act
        cut.Find("fluent-button").Click();

        // Assert
        Assert.True(clicked);
    }

    [Fact]
    public void FluentButton_StopPropagationFalse()
    {
        bool clickedondiv = false;
        bool clicked = false;

        // Arrange
        // Not adding StopPropagation here explicitly because it is false by default
        var cut = Render(@<div @onclick="@(e => {clickedondiv = true; })">
                            <FluentButton OnClick="@(e => { clicked = true; } )">
                                My button
                            </FluentButton>
                          </div>);

        // Act
        cut.Find("fluent-button").Click();

        // Assert
        Assert.True(clickedondiv);
        Assert.True(clicked);
    }

    [Fact]
    public void FluentButton_StopPropagationTrue()
    {
        bool clickedondiv = false;
        bool clicked = false;

        // Arrange
        var cut = Render(@<div @onclick="@(e => {clickedondiv = true; })">
                            <FluentButton StopPropagation="true" OnClick="@(e => { clicked = true; } )">
                                My button
                            </FluentButton>
                          </div>);

        // Act
        cut.Find("fluent-button").Click();

        // Assert
        Assert.False(clickedondiv);
        Assert.True(clicked);
    }
}
